import 'package:environmental_les_app/common/routes/route_names.dart';
import 'package:environmental_les_app/common/style/colours.dart';
import 'package:environmental_les_app/common/style/font_style.dart';
import 'package:environmental_les_app/common/widgets/common_widget.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';

class TaskItem extends StatelessWidget {
  final Map<String, dynamic> item;

  const TaskItem({super.key, required this.item});

  @override
  Widget build(BuildContext context) {
    return baseCardContainer(
        onTap: () => Get.toNamed(AppRoutes.taskDetailPage),
        content: [
          Row(
            children: [
              borderContainer(test: "工业废气", textColor: Colours.appMain),
              hGap8,
              Text(
                "RW20250420001",
                style: FontStyles.title,
              ),
              const Spacer(),
              statusTag(statusText: '待签收'),
            ],
          ),
          vGap10,
          backgroundContainer(
              padding: const EdgeInsets.symmetric(
                  horizontal: 10.0, vertical: 8.0), // 内边距
              child: Row(
                children: [
                  circularRing(color: Colours.lineFF5B05),
                  hGap5,
                  Container(
                    constraints: const BoxConstraints(maxWidth: 280),
                    child: Text(
                      "这是具体的描述信息这是具体的描述信息这是具体的描述信息",
                      style: FontStyles.textCustom09c(15),
                      overflow: TextOverflow.ellipsis,
                    ),
                  ),
                ],
              )),
          itemRowTwoStr(
              paddingTop: 8.0,
              paddingBottom: 0.0,
              icon: Icons.access_time,
              title: "完成时间:",
              rightWidget: Text(
                "2023-03-15 10:00",
                style: FontStyles.textCustom969(15),
              )),
          itemRowTwoStr(
              paddingTop: 8.0,
              paddingBottom: 0.0,
              icon: Icons.person_outline,
              title: "创建人:",
              rightWidget: Text(
                "张三",
                style: FontStyles.textCustom969(15),
              )),
          dividerLine(),
          vGap8,
          remainingTimeText("超时23分钟", Colours.statusError, "已督办")
        ]);
  }

  Widget remainingTimeText(String text, Color color, String status) {
    return Row(
      children: [
        Container(
          width: 4,
          height: 4,
          decoration: BoxDecoration(
            shape: BoxShape.circle,
            color: color,
          ),
        ),
        hGap8,
        Text(
          text,
          style: FontStyles.textCustom969(15)
              .copyWith(color: color, fontWeight: FontWeight.w500),
        ),
        hGap8,
        Text(
          status,
          style: FontStyles.textCustom969(15)
              .copyWith(color: color, fontWeight: FontWeight.w500),
        ),
      ],
    );
  }
}
